import $planet_GlobalDC_poof$ from "../../../frame/common/data.global.center";

export default class $planet_GameConfig_poof$ {
	private static $planet_user_id_poof$: number;
	private static $planet_coun_code_poof$: string;
	private static $planet_lang_code_poof$: string;
	private static $planet_device_id_poof$: string;

	/** 用户ID */
	public static get $planet_userID_poof$(){
		return $planet_GameConfig_poof$.$planet_user_id_poof$;
	}
	/** 设备ID */
	public static get $planet_deviceID_poof$(){
		return $planet_GameConfig_poof$.$planet_device_id_poof$;
	}
	/** 用户国家信息 */
	public static get $planet_country_poof$(){
		return $planet_GameConfig_poof$.$planet_coun_code_poof$;
	}
	/** 用户语言信息 */
	public static get $planet_language_poof$(){
		return $planet_GameConfig_poof$.$planet_lang_code_poof$;
	}

	public static async $planet_init_poof$(){
		$planet_GameConfig_poof$.$planet_user_id_poof$ = abd.$planet_local_poof$.$planet_read_poof$<number>('UID');
		let device_id = 'local-test';
		$planet_GameConfig_poof$.$planet_device_id_poof$ = device_id;

		if(!$planet_GameConfig_poof$.$planet_user_id_poof$){
			let country = 'US';
			let language = 'en';
			let user_id = 911;
			$planet_GameConfig_poof$.$planet_coun_code_poof$ = country;
			$planet_GameConfig_poof$.$planet_lang_code_poof$ = language;
			[$planet_GameConfig_poof$.$planet_user_id_poof$, $planet_GameConfig_poof$.$planet_coun_code_poof$, $planet_GameConfig_poof$.$planet_lang_code_poof$] =
			[user_id, country, language];

			(<const>[
				['UID', user_id],
				['COUNT', user_id],
				['LANG', user_id]
			]).forEach(([key, value])=> abd.$planet_local_poof$.$planet_save_poof$(key, value) );
		}else{
			[$planet_GameConfig_poof$.$planet_coun_code_poof$, $planet_GameConfig_poof$.$planet_lang_code_poof$] =
			['COUNT', 'LANG'].map(key=>abd.$planet_local_poof$.$planet_read_poof$<string>(key));
		}

		$planet_GlobalDC_poof$.$planet_trigger_poof$.$planet_CONFIG_LOADED_poof$ = true;
	}
}
